﻿using System;
using System.Collections.Generic;

namespace EstimationStudio.Core
{
    /// <summary>
    ///  The Ratings class represents a collection of modifier values for each level of <see cref="Rating"/>.
    /// </summary>
    [Serializable]
    public class AdjustmentVariability
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="AdjustmentVariability"/> class.
        /// </summary>
        public AdjustmentVariability() { }

        /// <summary>
        /// Initializes a new instance of the <see cref="AdjustmentVariability"/> class.
        /// </summary>
        /// <param name="veryLowValue">The very low value.</param>
        /// <param name="lowValue">The low value.</param>
        /// <param name="highValue">The high value.</param>
        /// <param name="veryHighValue">The very high value.</param>
        /// <param name="extraHighValue">The extra high value.</param>
        public AdjustmentVariability(Double veryLowValue, Double lowValue, Double highValue, Double veryHighValue, Double extraHighValue)
        {
            _Values[Rating.VeryLow] = veryLowValue;
            _Values[Rating.Low] = lowValue;
            _Values[Rating.Nominal] = 1.0;
            _Values[Rating.High] = highValue;
            _Values[Rating.VeryHigh] = veryHighValue;
            _Values[Rating.ExtraHigh] = extraHighValue;
        }

        Dictionary<Rating, Double> _Values = new Dictionary<Rating, Double>();

        /// <summary>
        /// Gets the modifier value with the specified <see cref="Rating"/>.
        /// </summary>
        /// <value></value>
        public Double this[Rating rating]
        {
            get
            {
                if (!_Values.ContainsKey(rating))
                    return 0.0;

                return _Values[rating];
            }
        }

        /// <summary>
        /// Gets the current influence based on the <see cref="AdjustmentVariability"/> current modifier values.
        /// </summary>
        /// <value>The influence.</value>
        public Double Influence
        {
            get { return new Formulas().Influence(this); }
        }
    }
}